
from time import sleep
from selenium import  webdriver

#打开163邮箱界面
driver=webdriver.Firefox()
driver.get('https://www.baidu.com/')
key_word=driver.find_element_by_name('wd').send_keys('163邮箱')
bt=driver.find_element_by_id('su').click()
sleep(3)
youxiang_css = 'div.result:nth-child(1) > h3:nth-child(1) > a:nth-child(1)'
driver.find_element_by_css_selector(youxiang_css).click()
sleep(5)

#登录邮箱
hds = driver.window_handles
driver.switch_to.window(hds[1])
iframe = driver.find_element_by_xpath('/html/body/div[2]/div[3]/div/div[3]/div[4]/div[1]/div[1]/iframe')
driver.switch_to.frame(iframe)
driver.find_element_by_name('email').send_keys('lzj97613')
driver.find_element_by_name('password').send_keys('老师这里的密码我给删掉了')
driver.find_element_by_id('dologin').click()
sleep(3)

#发送邮件
driver.switch_to.default_content()
driver.find_element_by_xpath("//*[@id='dvNavTop']/ul/li[2]/span[2]").click()
driver.find_element_by_class_name('nui-editableAddr-ipt').send_keys('ma_linpop@163.com')
driver.find_element_by_xpath("//*[@class='nui-ipt-input'and @type = 'text' and @tabindex = '1']").send_keys('化工学院_计171_李祖佳 自动化发送邮件')  # 添加主题
driver.switch_to.frame( driver.find_element_by_xpath("//iframe[contains(@class,'APP-editor-iframe')]"))
driver.find_element_by_class_name("nui-scroll").send_keys('吃葡萄不吐葡萄皮!!!')
driver.switch_to.default_content()  # 退出frame
driver.find_element_by_xpath("//*[@class='nui-toolbar-item']/div/span[2]").click()
sleep(5)





